// pages/home/home.js
var app = getApp();
Page({

  data: {
    // banner  的设置
    imgUrls:[
      "https://25335795.dayezi.club/caterDemo/banner1.png",
      "https://25335795.dayezi.club/caterDemo/banner2.png",
      "https://25335795.dayezi.club/caterDemo/banner3.png"
    ],
    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 1000,
    // 
    cuisineNav: [
      {
        title: '招牌菜品',
        type: 0
      },
      {
        title: '人气菜品',
        type: 1
      }
    ],
    currentTab:0,
    // 
    H:'',
    //招牌菜
    signDishList:[],
    //人气菜品
    hotDishList:[]
  },

  onLoad: function (options) {
    var that = this;
    var signDishList=[];
    var hotDishList=[];
    var dishList=app.data.dishList;
    hotDishList = dishList.slice(0,3);
    for(var i=0;i<dishList.length;i++){
      if (dishList[i].dish.signBoard===1){
        signDishList.push(dishList[i]);
      }
    }

    that.setData({
      signDishList: signDishList,
      hotDishList: hotDishList,
      showList: signDishList
    })
    var mobName = app.getSystemInfo().mob_name;
    if (mobName == "iPhone X"){
      that.setData({
        H: 720 +'rpx'
      })
    }else{
      that.setData({
        H: ''
      })
    }
    
  },
  //
  navTo:function(e){
    var that = this;
    var index=e.currentTarget.dataset.index;
    wx.setStorageSync("showDishDetails",that.data.showList[index]);
    app.pageTurns(e.currentTarget.dataset.url)
  } ,
  // 菜品nav
  tabNav:function(e){
    var that = this;
    var type=e.currentTarget.dataset.type;
    var showList = [];
    if(type===0){
      showList = that.data.signDishList
    } else if (type === 1) {
      showList = that.data.hotDishList
    }
    that.setData({
      currentTab: type,
      showList:showList
    })
  },
})